<?php
/**
 * User: fu
 * Date: 12-4-12
 * Time: 下午5:15
 */
require_once 'JumpController.php';

class MsgController extends  Zend_Controller_Action
{
    public function init(){
        $this->registry = Zend_Registry::getInstance();
        $this->view = $this->registry['view'];
    }

    public function indexAction(){
          $message=new Message();
          $this->view->msg=$message->fetchAll();
          echo $this->view->render('msgindex.phtml');
      }
      public function addAction(){
          $message=new Message();
          if(strtolower($_SERVER['REQUEST_METHOD'])=='post'){
                $title=$this->_request->getPost('tit');
                $content=$this->_request->getPost('cont');

                $message=new Message();
                $data=array(
                        'content'=>$content,
                        'title'=>$title
                );
                $message->insert($data);
                unset($data);
                $jump=new JumpController();
                $jump->jump('您增加数据成功!请您<a href="'.$this->view->baseUrl().'/msg/index/">返回</a>');
          }else{
              $this->view->msg=$message->fetchAll();
                echo $this->view->render('msgadd.phtml');
          }

      }
}
